import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    // 存储token
    Authorization: '',
    // 用户信息
    userinfo: {},
    // 功能模块
    sysMenuTree: []

  },
  mutations: {
    // 修改token，并将token存入localStorage
    changeLogin(state, user) {
      state.Authorization = user.Authorization;
      localStorage.setItem('Authorization', user.Authorization);
    },

    changeuserinfo(state, obj) {
      state.userinfo = obj.userinfo;
    },
    changesysMenuTree(state, obj) {
      state.sysMenuTree = obj.sysMenuTree;
    },
    clear(state) {
      state.Authorization = "";
      state.userinfo = {};
      state.sysMenuTree = []
    }
  }
});

export default store;
